package com.ruoyi.project.lely.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.R;
import com.ruoyi.project.lely.bean.entity.LyAddress;
import com.ruoyi.project.lely.bean.entity.LyCollect;
import com.ruoyi.project.lely.service.LyUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luoyong
 * @Desc: 类目菜单
 * @since 2022-01-13
 */
@Api(tags = "Mini-我的信息")
@RestController
@RequestMapping("/mini/mine")
public class MineController {

    @Autowired
    private LyUserService userService;

    @ApiOperation("查询我的基本数据")
    @GetMapping(value = "/getCount")
    public R getCount() {
        return userService.getCount();
    }

    @ApiOperation("查询我的收藏")
    @GetMapping(value = "/getCollect")
    public R getCollect(
            @ApiParam(value = "起始页", name = "pageNum") @RequestParam(defaultValue = "1") Integer pageNum,
            @ApiParam(value = "数量", name = "pageSize") @RequestParam(defaultValue = "10") Integer pageSize) {
        return userService.getCollect(new Page<LyCollect>(pageNum, pageSize));
    }

    @ApiOperation("查询我的地址")
    @GetMapping(value = "/getAddress")
    public R getAddress(
            @ApiParam(value = "起始页", name = "pageNum") @RequestParam(defaultValue = "1") Integer pageNum,
            @ApiParam(value = "数量", name = "pageSize") @RequestParam(defaultValue = "10") Integer pageSize) {
        return userService.getAddress(new Page<LyAddress>(pageNum, pageSize));
    }
}

